package com.qianfeng.zhangwei.volley;


import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.internal.widget.AdapterViewCompat;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.ListView;
import android.widget.Toast;

import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.view.annotation.ViewInject;
import com.lidroid.xutils.view.annotation.event.OnItemClick;



/**
 * A simple {@link Fragment} subclass.
 */
public class UtilsFragment extends Fragment{
    @ViewInject(R.id.xutils_listview)private ListView listView;
    @ViewInject(R.id.xutils_gridview)private GridView gridView;

    public UtilsFragment() {
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_utils, container, false);
        ViewUtils.inject(this,view);
        String[] lists = {"天天果园","让你笑不停","荔枝新闻","手游助手"};
        listView.setAdapter(new UtilsTestAdapter(getActivity(),lists));
        String[] grids = {"新余团购","让你笑不停","荔枝新闻","手游助手"};
        gridView.setAdapter(new UtilsTestAdapter(getActivity(),grids));
        return view;
    }
    @OnItemClick({R.id.xutils_listview,R.id.xutils_gridview})
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
        if (parent.getId()==R.id.xutils_listview){
            Toast.makeText(getActivity(),"listView"+position,Toast.LENGTH_LONG).show();
        }else if(parent.getId()==R.id.xutils_gridview){
            Toast.makeText(getActivity(),"gridview"+position,Toast.LENGTH_LONG).show();
        }
    }
}
